<template>
    <uxt-page :title="title">
        <uxt-bar-group title="设置">
            <uxt-color-selector-bar
                title="前景色"
                desc="color=xx/颜色值"
                v-model="color"
            ></uxt-color-selector-bar>
            <uxt-color-selector-bar
                title="背景色"
                desc="bg-color=xx/颜色值"
                v-model="bgColor"
                light
                gradual
            ></uxt-color-selector-bar>
            <uxt-bar title="时长" desc="duration">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '100rpx' }"
                        v-model="duration"
                    ></uxt-input>
                    ms
                </template>
            </uxt-bar>
            <uxt-bar title="图标" desc="icon">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '200rpx' }"
                        v-model="icon"
                    ></uxt-input>
                </template>
            </uxt-bar>
            <uxt-bar title="消息" desc="message">
                <template slot="right">
                    <uxt-input
                        classes="solid radius margin-xs"
                        :styles="{ width: '400rpx' }"
                        v-model="message"
                    ></uxt-input>
                </template>
            </uxt-bar>
            <uxt-single-selector-bar
                title="预设类型"
                desc="type"
                v-model="type"
                :options="types"
            ></uxt-single-selector-bar>
            <uxt-bar title="点击消息关闭">
                <template slot="right">
                    <uxt-switch v-model="click" radius size="sm"></uxt-switch>
                </template>
            </uxt-bar>
        </uxt-bar-group>
        <uxt-bar-group title="展示">
            <view class="padding bg-white text-center">
                <view class="padding bg-theme text-center round" @click="handleClick">
                    显示通知
                </view>
            </view>
        </uxt-bar-group>
    </uxt-page>
</template>

<script>
import uxtBarGroup from '@xtcoder/uxt/components/uxt-bar-group.vue'
import uxtColorSelectorBar from '@xtcoder/uxt/components/uxt-color-selector-bar.vue'
import uxtBar from '@xtcoder/uxt/components/uxt-bar.vue'
import uxtInput from '@xtcoder/uxt/components/uxt-input.vue'
import uxtSingleSelectorBar from '@xtcoder/uxt/components/uxt-single-selector-bar.vue'
import uxtSwitch from '@xtcoder/uxt/components/uxt-switch.vue'

export default {
    components: {
        uxtBarGroup,
        uxtColorSelectorBar,
        uxtBar,
        uxtInput,
        uxtSingleSelectorBar,
        uxtSwitch
    },
    data() {
        return {
            title: '消息通知',
            message: '消息通知',
            color: '',
            bgColor: 'theme',
            duration: 3000,
            icon: '',
            types: ['自定义', '主要消息', '成功消息', '警告消息', '危险消息'],
            typeValues: ['', 'primary', 'success', 'warn', 'danger'],
            type: 0,
            click: false
        }
    },
    methods: {
        handleClick() {
            this.uxtNotify({
                color: this.color,
                bgColor: this.bgColor,
                message: this.message,
                duration: !this.click && Number(this.duration),
                icon: this.icon,
                type: this.typeValues[this.type],
                click: () => {
                    this.click && this.uxtNotify().hide()
                }
            }).show()
        }
    }
}
</script>

<style lang="scss" scoped></style>
